<template>
  <a-modal
      :visible.sync="visible"
      title="选择三维模型"
      @cancel="handleCancel"
      width="300px"
  >
    <div class="model-list">
      <div
          v-for="model in modelOptions"
          :key="model.id"
          class="model-item"
          @click="handleSelect(model)"
      >
        {{ model.name }}
      </div>
    </div>
  </a-modal>
</template>

<script>
export default {
  name: 'ModelSelectModal',
  props: {
    visible: Boolean,
    modelOptions: {
      type: Array,
      required: true
    }
  },
  emits: ['update:visible', 'select'],
  methods: {
    handleCancel() {
      this.$emit('update:visible', false);
    },
    handleSelect(model) {
      this.$emit('select', model);
      this.$emit('update:visible', false);
    }
  }
};
</script>

<style scoped>
.model-list {
  margin-top: 16px;
}

.model-item {
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.model-item:hover {
  background-color: #f5f5f5;
}
</style>